"""
物品 VO
"""

import utils.enum_utils as enum
from models import (
    VOBase,
    VOPage,
)
from models.other import Dimensions
from my_typing import *
from utils.data_utils.special import ObjectIdStr
from utils.mock_utils import Demo
from utils.validator_utils.pydantic_validator.field import (
    CharField,
    DecimalField,
    IntegerField,
    ListField,
    NormalField,
)


class FamilyItemListVO(VOBase):
    """ 家庭 | 物品 | 列表 | VO """

    item_id: ObjectIdStr = CharField(..., title="物品 ID（ObjectId 字符串）", examples=[Demo.id])

    alias: StrOrNone = CharField(None, title="别名", min_length=3, max_length=32)
    position_id: ObjectIdStr = CharField(..., title="位置 ID（ObjectId 字符串）", examples=[Demo.id])
    name: str = CharField(..., title="名称", min_length=1, max_length=32)
    update_time: str = CharField(..., title="更新时间", min_length=19, max_length=19, examples=[Demo.dt_str])


class FamilyItemDetailVO(FamilyItemListVO):
    """ 家庭 | 物品 | 列表 | VO """

    brand: StrOrNone = CharField(None, title="品牌", max_length=32)
    category: enum.ItemCategory | None = CharField(None, title="物品类别")
    create_time: str = CharField(..., title="创建时间", min_length=19, max_length=19, examples=[Demo.date_str])
    colors: list[enum.Color] = ListField(default_factory=list, title="颜色列表")
    description: StrOrNone = CharField(None, title="描述", min_length=1, max_length=200)
    dimensions: Dimensions | None = NormalField(..., description="物品的尺寸（长宽高）")
    expire_date: DateOrNone = NormalField(None, title="过期日期")
    extra_info: DictOrNone = NormalField(default_factory=dict, title="额外信息")
    images: list[ObjectIdStr] = ListField(default_factory=list, title="图片列表")
    main_image: ObjectIdStr | None = CharField(None, title="主图")
    purchase_date: DateOrNone = NormalField(None, title="购买日期")
    price: FloatOrNone = DecimalField(None, title="价格", min_value=0, max_value=99999)
    size: enum.Size | None = CharField(None, title="尺寸")
    status: enum.ItemStatus = CharField(None, title="状态")
    tags: ListStr = ListField(default_factory=list, title="标签列表")
    valid_days: IntOrNone = IntegerField(None, title="有效期（天）", min_value=0, max_value=9999)


class FamilyItemListPage(VOPage[FamilyItemListVO]):
    """ 家庭 | 物品 | 列表 | 分页 """
